﻿@{
    ViewBag.Title = Local("Task.PageTitle");
}

@model List<TaskBase>
           
@if (Model != null)
{
<div class="box">
    <h3>@Local("Task.List")</h3>

    <table cellpadding="0" cellspacing="0">
        <thead>
            <tr>
                <td>@Local("Task.Type")</td>
                <td class="w150">@Local("Task.ExecuteTime")</td>
                <td class="w40">@Local("Task.Enabled")</td>
                <td class="w160">@Local("Task.LastExecuteTime")</td>
            </tr>
        </thead>
        <tbody class="hoverline">
        @foreach (var task in Model)
        { 
            <tr>
                <td>@task.Type</td>
                <td class="w150">@DisplayExecuteTime(task.ExecuteMode, task.ExecuteTime)</td>
                <td class="w40">@CPHelper.ShowBoolean(task.Enabled)</td>
                <td class="w160">@task.LastExecuteTime.ToLocalDateTimeString()</td>
            </tr>
        }
        </tbody>
    </table>
</div>
}

@helper DisplayExecuteTime(ExecuteMode mode, TimeSpan time)
{
    if(mode == ExecuteMode.Interval){<text>@GLocal(mode,time.ToSpanString())</text>}
    else{<text>@GLocal(mode)@time.ToString()</text>}
}